package com.zlm.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * 
 * @author luocj
 * @date 2015-1-5-下午2:07:44
 * @version 1.0.0
 * @Copyright © 2015 www.longsoftware.com
 */
public enum SkillsEnum {

	SKILL1(1,"编程"),
	SKILL2(2,"电脑"),
	SKILL3(3,"月嫂"),
	SKILL4(4,"驾驶"),
	SKILL5(5,"汽修"),
	SKILL6(6,"烹饪"),
	SKILL7(7,"理发"),
	SKILL8(8,"数控"),
	SKILL9(9,"电焊"),
	SKILL10(10,"车床"),
	SKILL11(11,"叉车"),
	SKILL12(12,"养殖"),
	SKILL13(13,"种植");

	private Integer code;
	private String name;


	private SkillsEnum(Integer code, String name){
		this.code=code;
		this.name=name;
	}

	//把枚举转成json
	public static String getJsonString(){
		StringBuilder builder = new StringBuilder("{");
		for(SkillsEnum skillsEnum:SkillsEnum.values()){
			builder.append("\""+skillsEnum.getCode()+"\":\""+ skillsEnum.getName()+"\",");
		}
		String json=builder.substring(0, builder.length()-1)+"}";
		return json;
	}


	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static List getSkills(){
		List list = new ArrayList();
		Map<String,Object> map;
		for(SkillsEnum skillsEnum:SkillsEnum.values()){
			map= new HashMap<String, Object>();
			map.put("code", skillsEnum.getCode());
			map.put("name", skillsEnum.getName());
			list.add(map);
		}
		return list;
	}

	public static  String getNameByCode(Integer code){
		for(SkillsEnum skillsEnum:SkillsEnum.values()){
			if(code.equals(skillsEnum.getCode())){
				return skillsEnum.getName();
			}
		}
		return null;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


}
